package huoye.shops.huoye.operation.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.codeideology.android.lang.entity.Paging;
import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import huoye.shops.base.BaseActivity;
import huoye.shops.base.PullToRefreshFragment;
import huoye.shops.huoye.operation.activity.DiscountCancelActivity;
import huoye.shops.huoye.operation.adapter.DiscountCancelAdapter;
import huoye.shops.huoye.operation.adapter.QueueShopAdapter;
import huoye.shops.huoye.operation.model.DiscountCancelData;
import huoye.shops.huoye.operation.model.QueueShopData;
import huoye.shops.huoye.operation.model.QueueShops;
import huoye.shops.huoye.operation.presenter.PrizeCancelPresenter;
import huoye.shops.huoye.operation.presenter.QueueShopPresenter;
import huoye.shops.huoye.operation.view.IPrizeCancelRefreshView;
import huoye.shops.huoye.operation.view.IQueueShopRefreshView;


public class QueueShopFragment extends PullToRefreshFragment<QueueShops> implements IQueueShopRefreshView {

    public static final int TYPE_QUENE_WAIT  = 0; //排队中
    public static final int TYPE_QUENE_RECORD = 1; //排队记录


    public static final String TYPE_KEY_EVENTID = "TYPE_KEY_EVENTID"; //	活动唯一标识

    private int mType;
    private String mEventId;
    private QueueShopPresenter mQueueShopPresenter;


    @Override
    public RecyclerViewAdapter createAdapter() {

        Bundle bundle = getArguments();
        mType = bundle.getInt(BaseActivity.EXTRAS_KEY_DATA);
        mEventId = bundle.getString(TYPE_KEY_EVENTID);
        QueueShopAdapter adapter = new QueueShopAdapter(getActivity(),mType);
        return adapter;
    }



    @Override
    protected void initView(View view, @Nullable Bundle bundle) {
        super.initView(view, bundle);

        mQueueShopPresenter = new QueueShopPresenter();
        mQueueShopPresenter.addTaskListener(this);
        mQueueShopPresenter.onStart();

        query();


    }



    @Override
    public void query(Paging paging) {
        super.query(paging);
        mQueueShopPresenter.getShopQueueList(mType,mEventId,paging);

    }


    public static QueueShopFragment getInstan(int type,String eventId) {
        QueueShopFragment fragment = new QueueShopFragment();
        Bundle bundle = new Bundle();
        bundle.putString("TYPE_KEY_EVENTID",eventId);
        bundle.putInt(BaseActivity.EXTRAS_KEY_DATA, type);
        fragment.setArguments(bundle);
        return fragment;

    }


    @Override
    public void onItemClick(QueueShops queueShops, int i, View view) {

    }
}
